﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.SessionState;

namespace RC1.teacher
{
    public partial class assignments : System.Web.UI.Page
    {
        int class_id;
        protected void Page_Load(object sender, EventArgs e)
        {
            class_id = Convert.ToInt32(Session["class_id"]);
        }

        private void addAssignment()
        {
            
            String name = TextBox1.Text;
            String desc = TextBox2.Text;
            DateTime date = DateTime.Parse(TextBox3.Text);
            
            int hour = Convert.ToInt32(TextBox4.Text);
            int min = Convert.ToInt32(TextBox5.Text);
            int sec = Convert.ToInt32(TextBox6.Text);

            DateTime deadline = new DateTime(date.Year, date.Month, date.Day, hour, min, sec, 0);

            tsu2011db4Entities1 db = new tsu2011db4Entities1();
            assignment a = new assignment()
            {
                assignment_title = name,
                assignment_description = desc,
                assignment_deadline = deadline,
                class_id = this.class_id
            };
            db.assignments.AddObject(a);
            db.SaveChanges();
            Response.Redirect("viewClass.aspx?id=" + class_id);
        
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            addAssignment();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("viewClass.aspx?id=" + class_id);
        }
    }
}